# Maintainer: Natanael Copa <ncopa@alpinelinux.org>

# this package is to resolve the circular dependency libva -> mesa -> libva

pkgname=libva-glx
pkgver=2.8.0
pkgrel=0
pkgdesc="Video Acceleration (VA) API for Linux with MESA support"
url="https://01.org/linuxmedia"
arch="all"
options="!check"  # No test suite.
license="MIT"
depends_dev="libva-dev mesa-dev libxfixes-dev"
makedepends="$depends_dev meson wayland-dev"
subpackages="$pkgname-dev"
source="libva-$pkgver.tar.gz::https://github.com/intel/libva/archive/$pkgver.tar.gz"
builddir="$srcdir"/libva-$pkgver

prepare() {
	( if [ -f "$startdir"/../libva/APKBUILD ]; then
		_v=$pkgver
		. "$startdir"/../libva/APKBUILD
		if [ "$_v" != "$pkgver" ]; then
			die "libva and libva-glx needs to be same version"
		fi
	fi )
	default_prepare
}

build() {
	meson builddir \
		--prefix=/usr \
		--buildtype=plain \
		-Dwith_glx=yes \
		-Dwith_wayland=yes
	ninja -C builddir
}

package() {
	DESTDIR="$pkgdir" ninja -C builddir install

	mkdir -p $builddir/temp/usr/lib/pkgconfig $builddir/temp/usr/include/va

	mv $pkgdir/usr/lib/libva-glx* $builddir/temp/usr/lib
	mv $pkgdir/usr/include/va/va_glx.h $builddir/temp/usr/include/va
	mv $pkgdir/usr/include/va/va_backend_glx.h $builddir/temp/usr/include/va
	mv $pkgdir/usr/lib/pkgconfig/libva-glx.pc $builddir/temp/usr/lib/pkgconfig
	rm -rf $pkgdir/*
	mv $builddir/temp/* $pkgdir
}

sha512sums="a6673c85205b68ba63cc9c61a1c30216cc29196843e659e91a41f64f1938c7ac3dbf0552bda32dd3dcf9dbf43695c8f29000eb6c9e41cb0db2aaaa10189ad502  libva-2.8.0.tar.gz"
